// /src下的api是     前台与后台服务器的通信

import {
    request
} from "../utils/request.js";
import UsersApi from "./admin.js";

export default {
    //  获取影院
    get: async ({
        curPage,
        eachPage
    }) => await request({
        // GET获取数据
        type: "GET",
        url: "/api/cinemas",
        data: {
            curPage,
            eachPage
        },
    }),

    // 影院删除
    remove: async (removeData, _id) => {
        return await request({
            type: 'delete',
            url: `/api/cinemas/${_id}`,
            data: removeData,
        })
    },

    // 新增影院
    add: async addCinema =>
        await request({
            type: 'post',
            url: '/api/cinemas',
            data: addCinema,
        }),

    //更新影院 
    update: async (newData, _id) => {
        return await request({
            type: "put",
            url: `/api/cinemas/${_id}`,
            data: newData,
        })
    },
    // 查找_id相关信息
    getOne: async _id =>
        await request({
            type: 'get',
            url: `/api/cinemas/${_id}`,
        }),

    // 删除图片
    deleteImg: async ({
            _id,
            url
        }) =>
        await request({
            type: 'delete',
            url: `/resource/cinemas/${_id}/imgs/${encodeURIComponent(url)}`,
        }),
    // 找到所有电影信息
    select: async data =>
        await request({
            type: "get",
            url: "/api/cinemas/select",
            data: data
        }),

}